package com.dataexa.ky.jefflow.exception;

import java.lang.reflect.Modifier;

/**
 * 错误编码定义
 * @program: PostGirl-panent
 * @description: ErrorCode
 * @author: Cheng Zhi
 * @create: 2021-03-11 20:03
 **/
public class ErrorCode {

    /**
     * 业务异常使用1xxxx
     */
    @ErrorMessage(text = "文件解析异常")
    public static final String FILE_ANALYSE_ERROR = "10000";

    @ErrorMessage(text = "文件入库异常")
    public static final String FILE_UPLOAD_ERROR = "10001";

    @ErrorMessage(text = "异常请求,请登录后再访问")
    public static final String NO_TOKEN_REQUEST_ERROR = "10002";

    @ErrorMessage(text = "尚未登录，请登录")
    public static final String NO_LOGIN_REQUEST_ERROR = "10003";

    @ErrorMessage(text = "权限不足，禁止访问")
    public static final String NO_POWER_REQUEST_ERROR = "10004";

    @ErrorMessage(text = "请求参数不可为空, 请检查")
    public static final String REQUEST_IS_NULL_ERROR = "10005";

    /**
     * netty组件异常使用2xxxx
     */
    @ErrorMessage(text = "请求参数[{0}]不可为空, 请检查！")
    public static final String PARAMTER_IS_NULL_ERROR = "20001";

    @ErrorMessage(text = "请求参数[{0}]不可小于等于0, 请检查！")
    public static final String PARAMTER_NOT_GREATER_ZERO_ERROR = "20002";

    /**
     * JEF-FLOW组件异常使用3xxxx
     */
    @ErrorMessage(text = "节点[{0}]实现类枚举未找到，请检查！")
    public static final String JEF_FLOW_NODE_ENUM_IS_NULL_ERROR = "30001";
    @ErrorMessage(text = "节点[{0}]具体实现类未找到，请检查！")
    public static final String JEF_FLOW_NODE_IMPL_IS_NULL_ERROR = "30002";

    public static void main(String[] args) throws IllegalAccessException {
        java.lang.reflect.Field[] fields = ErrorCode.class.getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            java.lang.reflect.Field field = fields[i];
            if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
                String name = field.getName();
                String code = field.get(null).toString();
                String msg = "";
                if (field.getAnnotation(ErrorMessage.class) != null) {
                    msg = field.getAnnotation(ErrorMessage.class).text();
                }
                System.out.println(""+code+"~"+name+"~"+msg);
            }
        }
    }
}
